
***************************************************************************
* replication code for "Explaining Incompleteness and Conditionality in Alliance Agreements"
***************************************************************************

* set working directory
* cd "~/Desktop/"

* read in data
use "replication_data.dta", clear

***************************************************************************
* main models
***************************************************************************

* Table 1, Model 1
sureg (not_incomplete democracy wartime count_members asymmetric similarity) (incomplete democracy wartime count_members asymmetric similarity), corr

* Table 1, Model 2
sureg (not_incomplete democracy wartime count_members asymmetric similarity) (incomplete_no_defense_only democracy wartime count_members asymmetric similarity), corr

***************************************************************************
* Bayesian model
***************************************************************************

* multivariate Bayesian regression
bayes, rseed(3728): mvreg not_incomplete incomplete = democracy wartime count_members asymmetric similarity

* diagnostic plots for independent variable of interest
bayesgraph diagnostics {not_incomplete:democracy}
bayesgraph diagnostics {incomplete:democracy}

* probability that the effect of democracy on each dependent variable is positive (independent tests)
bayestest interval ({not_incomplete:democracy}, upper(0)) ({incomplete:democracy}, lower(0))

* probability that the effect of democracy on not incomplete conditions is less than the estimated effect on incomplete conditions
bayestest interval ({not_incomplete:democracy}, upper(0.235164))

* joint probability that the effect of democracy on incomplete conditions is positive
* and that the effect of democracy on not incomplete conditions is less than the estimated effect on incomplete conditions
bayestest interval (({not_incomplete:democracy}, upper(0.235164)) ({incomplete:democracy}, lower(0)), joint)

***************************************************************************
* robustness tests
***************************************************************************

* test 1: separate OLS models
reg not_incomplete democracy wartime count_members asymmetric similarity
reg incomplete democracy wartime count_members asymmetric similarity

* test 2: separate ordered logit models
ologit not_incomplete democracy wartime count_members asymmetric similarity
ologit incomplete democracy wartime count_members asymmetric similarity

* test 3: bilateral alliance dummy
sureg (not_incomplete democracy wartime bilateral asymmetric similarity) (incomplete democracy wartime bilateral asymmetric  similarity), corr 

* test 4: different Polity thresholds
sureg (not_incomplete democracy_6 wartime count_members asymmetric similarity) (incomplete democracy_6 wartime count_members asymmetric similarity ), corr
sureg (not_incomplete democracy_4 wartime count_members asymmetric similarity) (incomplete democracy_4 wartime count_members asymmetric similarity ), corr

* test 5: post-1945 dummy
sureg (not_incomplete democracy wartime count_members asymmetric similarity post_1945) (incomplete democracy wartime count_members asymmetric similarity post_1945), corr

* test 6: change Europe coding for geography variables
sureg (not_incomplete_no_europe democracy wartime count_members asymmetric similarity) (incomplete_no_europe democracy wartime count_members asymmetric similarity), corr

* test 7: offensive war provisions dummy
sureg (not_incomplete democracy wartime count_members asymmetric similarity offensive_war) (incomplete democracy wartime count_members asymmetric similarity offensive_war), corr

* test 8: recode dependent variables as dummies
sureg (not_incomplete_dummy democracy wartime count_members asymmetric similarity) (incomplete_dummy democracy wartime count_members asymmetric similarity), corr

***************************************************************************
* end .do file
***************************************************************************
